#include <stdio.h>
#include <tchar.h>
#include <windows.h>

#define CONSOLE_PARAM_MAIN

#ifndef CONSOLE_PARAM_MAIN

	void main()
	{
		TCHAR szCmdLineInfo[MAX_PATH * 3]	= {0};
		_stprintf(szCmdLineInfo, _T("command line: \n %s"), GetCommandLine());
		MessageBox(GetDesktopWindow(), szCmdLineInfo, _T("I Come from < void main() > function"), MB_OK);
	}

#else

	void main(int argc, char* argv[])
	{
		TCHAR szTmp[MAX_PATH]				= {0};
		TCHAR szCmdLineInfo[MAX_PATH * 3]	= {0};

		_tcscpy(szCmdLineInfo, _T("command line: "));
		for (int ii = 0; ii < argc; ii++)
		{
	#ifdef _UNICODE
			TCHAR szBuf[MAX_PATH];
			mbstowcs(szBuf, argv[ii], MAX_PATH);
			_stprintf(szTmp, _T("\n%d: %s "), ii + 1, szBuf);
	#else
			_stprintf(szTmp, _T("\n%d: %s "), ii + 1, argv[ii]);
	#endif
			_tcscat(szCmdLineInfo, szTmp);
		}

		MessageBox(GetDesktopWindow(), szCmdLineInfo,  _T("I Come from < void main(int, char*) > function"), MB_OK);

		return;
	}
#endif

BOOL WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE hPreInstance, LPTSTR lpszCmdLine, int nShowCmd)
{
	TCHAR szCmdLineInfo[MAX_PATH * 3];
	if (NULL != lpszCmdLine && NULL != *lpszCmdLine)
	{
		_stprintf(szCmdLineInfo, _T("command line:  [ %s ]"), lpszCmdLine);
	} else {
		_tcscpy(szCmdLineInfo, _T("hav't set the command line!"));
	}

	MessageBox(GetDesktopWindow(), szCmdLineInfo,  _T("I Come from < BOOL _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int) > function"), MB_OK);

	//==: if this cmdline is exe file path, will startup it
	if (NULL != lpszCmdLine && NULL != *lpszCmdLine && NULL != _tcsstr(lpszCmdLine, _T(".exe")))
	{
		ShellExecute(NULL, _T("open"), lpszCmdLine, NULL, NULL, SW_SHOWNORMAL);
	}

	return TRUE;
}
